﻿
@using CML.Intercamber.Business

@if (ViewBag.ConnectedUserInfo != null)
{
    Users connectedUser = ViewBag.ConnectedUserInfo;
    <script>
        $(function () {
            $(".leftButton").button();
            updateScore(@connectedUser.Score);
            refreshUnreadMessagesCount(null, false);
        });
        function updateScore(nb) {
            var txt = "@Resources.Intercamber.LeftBar_Points";
            $("#nbPoints").html(txt.replace("{0}", nb));
        }
        function updateUnreadMessages(nb) {
            var txt = "@Resources.Intercamber.LeftBar_NbUnreadMessages";
            $("#nbMessages").html(nb > 0 ? txt.replace("{0}", nb) : "");
        }
        
    </script>
    <br />
	if (!String.IsNullOrEmpty(ViewBag.ConnectedUserInfo.IdCountry))
	{
    <img style="position: relative; padding-left: 130px; margin-bottom: -25px; margin-top: -5px;" src="~/Images/RoundFlagsSmall/RoundFlag_@(ViewBag.ConnectedUserInfo.IdCountry).png" />
	}
    <img style="width:140px;" src="@Url.Content(connectedUser.PhotoDirectory == null || connectedUser.PhotoProfile == null ? "~/Images/NoAvatar.png" : "~/Images/_upload_/" + connectedUser.PhotoDirectory  +"/" + connectedUser.PhotoProfile + ".png")" class="ui-corner-all" />
    <br />
    <br />

    <div align="left">
        <span class="leftButton" onclick="document.location='/Profile/MyProfile';" id="leftButtonProfile">
            <span class="infoBarTitle" style="" title="@Resources.Intercamber.LeftBar_MyProfile">
                @(ViewBag.ConnectedUserInfo != null ? ViewBag.ConnectedUserInfo.UserNameComplete : "null")
            </span>
            <span class="infoBarSubTitle" id="nbPoints">
                LeftBar_Points
            </span>
        </span>
        <br />
        <br />
        <span class="leftButton" onclick="document.location='/Contact/MyPenpals';" id="leftButtonPenpals">
            <span class="infoBarTitle">@Resources.Intercamber.LeftBar_MyPenpals</span>
            <br />
            <span class="buttonSimpleText">
                @(ViewBag.NumContactRequests == 0 ? "" : String.Format(Resources.Intercamber.LeftBar_NContactRequests, ViewBag.NumContactRequests))
            </span>
        </span>
        <br />
        <br />
        <span class="leftButton" onclick="document.location='/Talk/MyDiscussions';"  id="leftButtonDiscussions">
            <span class="infoBarTitle">@Resources.Intercamber.LeftBar_MyDiscussions</span>
            <br />
            <span class="infoBarSubTitle" id="nbMessages">
                @(ViewBag.NumUnreadMessages == 0 ? "" : String.Format(Resources.Intercamber.LeftBar_NbUnreadMessages, ViewBag.NumUnreadMessages))
            </span>
            @*LeftBar_NNewMessages
            LeftBar_0NewMessages*@
        </span>
    </div>
}
